package com.gy.pinduoduo;

import java.util.Scanner;

public class demo4 {
    public static void main(String[] args) {

        Scanner scanner=new Scanner(System.in);
        int num=scanner.nextInt();//牌的数量
        int[][] arr=new int[2][num];
        int A=0;//多多鸡的筹码数
        int B=0;//多多鸭的筹码数

        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < num; j++) {
                arr[i][j]=scanner.nextInt();
            }
        }

        int[] a=new int[num*2];                 
        int point=0;
        for (int i = 0; i < num; i++) {
            a[point]=arr[0][i];
            point++;
            if (point>1){
                for (int j = 0; j < point; j++) {
                    if (a[j]==a[point]){
                        A+=point-i;
                        point=i;
                    }
                }
            }
            a[point]=arr[1][i];
            point++;
            if (point>1){
                for (int j = 0; j < point; j++) {
                    if (a[j]==a[point]){
                        B+=point-i;
                        point=i;
                    }
                }
            }
        }
        for (int i = 0; i < point; i++) {
            if (i%2==0){
                B++;
            }else {
                A++;
            }
        }

        System.out.println(A+" "+B);

    }

}
